<?php

/*
 * This file is part of the Geek-Zoo Projects.
 *
 * @copyright (c) 2010 Geek-Zoo Projects More info http://www.geek-zoo.com
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License
 * @author xuanyan <xuanyan@geek-zoo.com>
 *
 */

require_once ROOT_PATH.'/Abstract/front_abstract.php';

class Action extends front_abstract
{
    function index()
    {
        
        if( !strip_tags(_POST('old')) && !strip_tags(_POST('ne')) && !strip_tags(_POST('com')) ){
            exit('请输入内容!');
        }elseif( strip_tags(_POST('ne')) != strip_tags(_POST('com')) ){
            exit('新密码两次输入结果不同!');
        }
        
        $old = sha1( strip_tags(_POST('old')) );
        $ne = sha1( strip_tags(_POST('ne')) );
        $user = _model('user')->read(array('id'=>"{$_SESSION['user']['id']}"));
        if( $user['password'] != $old ){
            exit('旧密码输入有误!');
        }
        if( !_model('user')->update( array('id'=>"{$_SESSION['user']['id']}"), array('password'=>"$ne") ) ){
            exit("修改失败");
        }
        exit('1');
    }
}
?>
